package com.transcargo.data;

/**
 * Date: 17.02.2011
 * Time: 23:22:43
 */
import java.util.ArrayList;
import java.util.Iterator;

import com.transcargo.db.db;
import com.transcargo.geo.Country;

public class CountriesData {

    public static Country[] getCountries(db Db) throws NumberFormatException, Exception {
        Country[] countries = null;
        int num_countries = 0;
		ArrayList<String[]> list = Db.execute("SELECT id FROM countries");
		if (list != null) {
			Iterator<String[]> iter =list.iterator();
			num_countries = list.size();
			countries = new Country[num_countries];
			int i = 0;
			while (iter.hasNext()) {
				String ctr[] = iter.next();
				countries[i] = new Country(Integer.parseInt(ctr[0]), false, Db);
				i++;
			}
		}
        return countries;
    }

}
